package shapes;

public class Diamond extends Shapes {

    IsocelesTriangle upperHalf, lowerHalf;
    HorizontalLine middleLine;
    int height;

    public Diamond(int height) {
        this.height = height;
        upperHalf = new IsocelesTriangle(height - 1);
        lowerHalf = new IsocelesTriangle(height - 1);
        middleLine = new HorizontalLine(2 * height - 1);
    }

    @Override
    public void create() {
        upperHalf.createLeftIndentedIsocelesTriangle(1);
        middleLine.create();
        lowerHalf.createLeftIndentedInvertedIsocelesTriangle(1);
    }

    @Override
    public String dataToString() {
        StringBuilder outputString = new StringBuilder(2*height*height);
        for (int i = 0; i < height; i++) {
            outputString.append(data[i]);
            outputString.append('\n');
        }
        return outputString.toString();
    }

    public void drawDiamondWithName() {
        create();
        middleLine.modifyLineData("name");
    }
}
